package com.jt.controller;

import com.jt.pojo.User;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

//@Controller //将类交给SpringMVC管理
//@ResponseBody //当前类中的所有方法 都返回JSON串
@RestController // = @Controller + @ResponseBody
@RequestMapping("/rest")
public class RestUserController {

    /**
     * 注意事项:
     *      1.springMVC中的请求路径不能重复!!!!
     *      2.可以@RequestMapping("/业务名称")自定义前缀
     * URL地址:http://localhost:8080/rest/findJSON?name=tomcat&age=18
     * @return
     */
    @RequestMapping("/findJSON")
    public User findUser(User user){
        user.setId(105);
        user.setSex("男");
        return user;
    }
}
